import request from '@/utils/request'

// 获取群组消息历史
export function getGroupMessages(groupId) {
  return request({
    url: `/api/GroupChat/groups/${groupId}/messages`,
    method: 'get'
  })
}

// 获取用户的所有群组
export function getUserGroups() {
  return request({
    url: '/api/GroupChat/groups',
    method: 'get'
  })
}

// 创建新群聊
export function createGroup(data) {
  return request({
    url: '/api/GroupChat/groups',
    method: 'post',
    data
  })
}

// 获取群组详情
export function getGroupDetail(groupId) {
  return request({
    url: `/api/GroupChat/groups/${groupId}`,
    method: 'get'
  })
}

// 加入群组
export function joinGroup(groupId) {
  return request({
    url: `/api/GroupChat/groups/${groupId}/join`,
    method: 'post'
  })
}

// 离开群组
export function leaveGroup(groupId) {
  return request({
    url: `/api/GroupChat/groups/${groupId}/leave`,
    method: 'post'
  })
}

// 获取群组成员
export function getGroupMembers(groupId) {
  return request({
    url: `/api/GroupChat/groups/${groupId}/members`,
    method: 'get'
  })
}

// 添加群组成员
export function addGroupMembers(groupId, data) {
  return request({
    url: `/api/GroupChat/groups/${groupId}/members`,
    method: 'post',
    data
  })
}

// 移除群组成员
export function removeGroupMember(groupId, userId) {
  return request({
    url: `/api/GroupChat/groups/${groupId}/members/${userId}`,
    method: 'delete'
  })
} 